﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using iBuproModel.Repositories.Interfaces;
using IBupro.Models.Classes;
using iBuproModel;
using IBupro.Classes;

namespace IBupro.Models
{
    public class StudentProjectSearchModel : CustomModel
    {
        public int StudentFieldId { get; set; }
        public int SubjectId { get; set; }
        public string SearchString { get; set; }
        public IEnumerable<iBuproModel.Project> ProjectList { get; set; }
        public bool FreeOnly { get; set; }

        public SelectList GetStudentFieldList()
        {
            IStudentFieldRepository fields = repositoryService.StudentFieldRepositoryCreateInstance();
            return new SelectList(fields.GetAll(), "Id", "Name");
        }

        public SelectList GetSubjectList()
        {

            ISubjectRepository subjects = repositoryService.SubjectRepositoryCreateInstace();
            List<Subject> list = new List<Subject>();
            list.Add(new Subject()
            {
                Id=0,
                Name = Translator.Instance["all"]
            });
              list.AddRange(subjects.GetAll(s => s.StudentFields.FirstOrDefault(f => f.Id == StudentFieldId) != null).ToList());
            

            return new SelectList(list, "Id", "Name");
        }

    }
}